/**
 * 
 */
package org.codesketch.collector.controller;

import org.codesketch.collector.service.RecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

/**
 * @author Quirno Brizi
 *
 */
@Controller
@RequestMapping(value="/record")
class RecordController {

	@Autowired
	private transient RecordService service;
	
	@ResponseStatus(HttpStatus.ACCEPTED)
	@RequestMapping(value="create", method=RequestMethod.POST, consumes="text/xml")
	public void create(@RequestBody String record) {
		service.create(record);
	}
	
	@ResponseStatus(HttpStatus.OK)
	@RequestMapping(value="ping", method={RequestMethod.HEAD, RequestMethod.GET}, produces="text/plain")
	public @ResponseBody String ping() {
		return "pong";
	}
}
